<HTML><HEAD><TITLE>~ +Goal</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Control</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>~ +Goal</H1>
The sound negation operator.  If Goal is not ground, the predicate delays.


<DL>
<DT><EM>Goal</EM></DT>
<DD>Callable term or a variable.
</DD>
</DL>
<H2>Description</H2>

   This is the sound negation operator.  It can be used instead of
   not/1, or \+/1 (the negation as failure operators).  It is known
   that negation as failure may yield non-logical results if the Goal
   contains free variables.  To avoid this, ~/1 delays if Goal is not
   ground.  If the free variables are bound later in the execution,
   the delayed predicate is woken and executed and may yield success
   or failure.  While ~/1 always behaves logically, in some cases it
   delays where negation as failure or constructive negation would
   have immediately (and correctly) failed.

<P>

<H3>Modes and Determinism</H3><UL>
<LI>~(+) is semidet
</UL>
<H3>Modules</H3>
This predicate is sensitive to its module context (tool predicate, see @/2).
<H3>Fail Conditions</H3>
Fails if Goal can be satisfied
<H2>Examples</H2>
<PRE>
Success:
    ~ 3 = 4.
    ~ 3 = X,            (delays ...
        X = 4.             ... and succeeds with X = 4)
Fail:
    ~ 3 = 3.
    ~ 3 = X,            (delays ...
        X = 3.             ... and fails)
    ~ X = X,            (delays ...
        X = 3.             ... and fails)



</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/control/not-1.html">not / 1</A>, <A HREF="../../kernel/control/RP-1.html">\+ / 1</A>, <A HREF="../../kernel/suspensions/suspend-3.html">suspend / 3</A>
</BODY></HTML>
